<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户登录</title>
		<link rel="stylesheet" href="bootstrap.min.css">
		<style>
			.wrap{
				width: 1000px;
				margin:100px auto;
			}
		</style>
	</head>
	<body>
		
		<div class='wrap'>
			<h2>用户登录</h2>
			<hr>
			<div class="form-group">
				<label for="username">用户名</label>
				<input type="email" class="form-control" id="username" placeholder="请输入用户名">
			</div>
			<div class="form-group">
				<label for="password">密码</label>
				<input type="password" class="form-control" id="password" placeholder="请输入密码">
			</div>

			<div class="checkbox">
				<label>
					<input type="checkbox"> 30天内免登陆
				</label>
			</div>
			<button type="submit" class="btn btn-primary" id="login">登录</button>
		</div>
		<script src="jquery.min.js"></script>
		<script src="common.js"></script>
		<script>
			$("#login").click(function(){
				$.ajax({
					url:`${url}/login`,
					data:{
						username:$("#username").val(),
						password:$("#password").val()
					},
					success(data){
						if(data === "error"){
							alert("用户名或密码错误");
						}
						else{
							sessionStorage.setItem("username",data);
							location.href = `${url}/`
						}
					}
				})
			})

		</script>
	</body>
</html>
